import 'package:flutter/material.dart';
import 'package:flutter_doubanmovie/HotMovies/hotMovieData.dart';
import 'package:flutter_doubanmovie/HotMovies/hotMovieItem.dart';

class HotMoviesList extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return HotMoviesListState();
  }
}

class HotMoviesListState extends State<HotMoviesList> {
  List<HotMovieData> hotMovies = new List<HotMovieData>();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    var data = HotMovieData('反贪风暴4', 6.3, '林德禄', '古天乐/郑嘉颖/林峯', 29013,
        'https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2551353482.webp');
    setState(() {
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
      hotMovies.add(data);
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MediaQuery.removePadding(
      removeTop: true,
      context: context,
      child: ListView.separated(
        itemCount: hotMovies.length,
        itemBuilder: (context, index) {
          return HotMovieItem(hotMovies[index]);
        },
        separatorBuilder: (context, index) => Divider(
          height: 1,
          color: Colors.black26,
        ),
      ),
    );
  }
}
